Expo won't build with locally installed NPM packages - expo

I am using expo#43.0.3 (and expo-cli#5.0.3) to manage my react native project and I have to install an npm package from local source:
$ npm install /path/to/mypackage
In my package.json the package is successfully linked via
"dependencies": {
...
"myPackage": "file:../../mypackage",
...
}
I can also confirm the package works when installing to a new plain node project (same node version 14.8.2)
Now when I start expo via expo start and navigate to the app it does not throw any error but only a warning:
› Reloading apps
warn No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.
When using the package from registry everything builds, however.
I tried to use the private packages section form the expo docs, but they only describe how to use private packages from registry but not local.
Anything I'm missing here?
edit:
After resetting the expo network adapters it loads the bundle but it now says it can't find the package:
Unable to resolve module myPackage from /home/user/path/to/myPackage/file.js: myPackage could not be found within the project or in these directories:
node_modules
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
However, I'm not using watchman and I'm not using yarn and rmoving metro- folders from /tmp did not make a difference.

As it turned out in this issue on GitHub it can be solved via npm pack:
run npm pack inside of your library and then npm install path/to/the/packed/file.tgz from your project
Which worked fine for the setup I described in the question.

Related

VSTS Bower not found

We are using Visual Studio Team Services for build and deployment of several sites. Some .NET and some are not. All working fine when using the hosted agent. Due to performance issues and long queue times for the hosted agent we need to use our own build agent.
Here comes the problem:
When running the VSTS builds we get an error when running bower:
******************************************************************************
Starting: bower install
******************************************************************************
C:\Program Files (x86)\nodejs\npm.cmd install -g bower
C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm\bower -> C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm\node_modules\bower\bin\bower
bower#1.7.9 C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm\node_modules\bower
Not found bower: null
******************************************************************************
Finishing: bower install
******************************************************************************
The problem is that bower is actually in that location:
And here are the actual bower build step:
How can we fix this Not found bower: null error?
There are known issues with tools installed into profile folders it has to do with permissions. It's easier to install the tool from an administrative console with the -g parameter. And ensure that the central NPM version is added to the service or system's %path% environment variable.
Or pass in a specific location by adding additional parameters to the call to npm: npm install --prefix "$(Agent.WorkFolder)" Bower Then specify the same location in the Advanced section of the Bower task.
Bower CLI location: $(Agent.WorkFolder)\node_modules\
(You'd need to check the exact location the package is installed to, I'm slightly guessing at the moment ;)).

Using Gulp with Visual Studio Team Services

I'm looking to set up automated builds with Visual Studio Team Services but I keep running into trouble. My build definition:
npm install gulp
npm install --save-dev jshint gulp-jshint ruby
npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
gem install sass
gulp
The build fails when attempting to install the sass gem with "'gem' is not recognized as an internal or external command". If I build without installing the sass gem first, gulp will fail with "'sass' is not recognized as an internal or external command". Anyone have experience with getting sass to work in Visual Studio Team Services?
There seem to be several issue here. First you might need to make you familiar how npm works, whats the meaning of --save-dev and whats the difference between local and globally installed modules.
--save-dev is used to save the package for development purpose, while --save is used to save the package required for the application to run. Both are commands which you run on your development machine and you put the resulting package.json under version control.
On the build server you will just run an npm install which will restore all the packages listed in the package.json.
These is for local modules. You can also install modules globally using the -g flag. This will store them outside of your current project, and binaries will be available in your PATH variable. Modules which you need inside your project (using require) need to be installed locally. Modules you'll call from the shell (eg gulp-cli) need to be installed globally.
Therefore what you need to do:
On your development machine add all local npm modules using npm install with either the --save or --save-dev flag.
Put the resulting package.json file under version control.
On the build server you need to make sure that all required global npm modules are installed.
Call npm install using the VSTS npm task to restore the local npm modules. You won't need to specify which modules need to be installed, since they're already listed in the package.json file.
Call gulp using the VSTS gulp task with the appropriate arguments.

ENOENT error when doing ionic start

I upgraded to beta.23 and started to get an error when created a new project using 'ionic start foo --v2 --verbose'.
The error in red says
"Unable to spawn commandError: spawn npm ENOENT (CLI v2.0.0-beta.23)."
I have npm installed and can run from Windows 8 cmd line.
I tried upgrade to node v5.9.1.
I confirmed npm is in the PATH environment variable and can run npm from cmd shell.
Any ideas how to fix or debug further would be appreciated.
Here is the complete output:
C:\ionic2>ionic start foo --v2 --verbose
Task setting: title=start, name=start, summary=Starts a new Ionic project in the
specified PATH, [options]=any flags for the command, <PATH>=directory for the n
ew project, [template]=Starter templates can either come from a named template,
(ex: tabs, sidemenu, blank),
a Github repo, a Codepen url, or a local directory.
Codepen url,
Defaults to Ionic "tabs" starter template, --appname|-a=Human readable name for
the app (Use quotes around the name), --id|-i=Package name for <widget id> confi
g, ex: com.mycompany.myapp, title=Skip npm package installation, boolean=true, t
itle=Create a basic structure without Cordova requirements, boolean=true, title=
Setup the project to use Sass CSS precompiling, boolean=true, title=List starter
templates available, boolean=true, --io-app-id=The Ionic.io app ID to use, --te
mplate|-t=Project starter template, boolean=true, title=Start a Ionic v2 project
, boolean=true, title=(with --v2 only) Use TypeScript in starter, --zip-file|-z=
URL to download zipfile for starter template, module=./ionic/start, disableChang
ePwd=true
Utils.preprocessCliOptions _=[start, foo], skip-npm=false, no-cordova=false, w=f
alse, sass=false, s=false, list=false, l=false, v2=true, v=false, typescript=fal
se, -ts=false, verbose=true, $0=C:\Program Files\nodejs\node.exe C:\Users\bradtk
e\AppData\Roaming\npm\node_modules\ionic\bin\ionic
One awesome Ionic app coming right up...
Creating Ionic app in folder C:\ionic2\foo based on tabs project
Downloading: https://github.com/driftyco/ionic2-app-base/archive/master.zip
[=============================] 100% 0.0s
Downloading: https://github.com/driftyco/ionic2-starter-
tabs/archive/master.zip
[=============================] 100% 0.0s
Installing npm packages...
Running exec command: npminstall
Utils.fail Unable to run spawn commandError: spawn npm ENOENT undefined
Utils.fail stack undefined
Utils.errorHandler is set, calling that now
Cli.Utils.errorHandler msg Unable to run spawn commandError: spawn npm ENOENT st
ring
Unable to run spawn commandError: spawn npm ENOENT (CLI v2.0.0-beta.23)
Your system information:
Cordova CLI: 6.1.0 (cordova-lib#undefined)
Ionic CLI Version: 2.0.0-beta.23
Ionic App Lib Version: 2.0.0-beta.13
OS: Windows 8.1
Node Version: v5.9.1
Regards,
bruce
I have the exact same issue. Worked in beta 22.
Reverting to the earlier beta resolved the issue:
npm install -g ionic#2.0.0-beta.22
Move into folder of your application and run npm install. I don't know what is happening but sound like start script trying to execute npminstall rather than npm install:
Installing npm packages...
Running exec command: npminstall
This is a known issue with the CLI on windows. Downgrading to cli beta22 can work as workaround for now, but this will be fixed in the next release
Upgrading npm worked for me.
npm install -g npm

Ember JS: define is not defined

I recently upgraded my app from Ember 1.3 to Ember 2.4.2. However after deploying it to my production environment with ember build --env production I noticed a couple of issues.
The first issue was that each script/stylesheet tag had a integrity attribute attached to it which made it impossible to load those resources. After some investigation I decided to just replace the value for those attributes to be empty. This allowed the app to download the resources but I then noticed an error in the console that said define is not defined on the minified website.js file that Ember creates. I'm unable to replicate this issue locally because the app runs fine. What steps can I additionally take to investigate this issue? Could this be related to some addon that I have installed, or maybe the SRI integrity attribute that I removed?
Edit: I just tried building and deploying a vanilla app with Ember (e.g. ember new testApp and ember build --env production and encountered the same issue. Is there an issue with Ember that I don't know about? I don't think it's my server since I'm able to render a plain index.html just fine.
I prefer to use the latest NodeJS (v5.8) and the latest npm.
You can update your npm with npm install -g npm.
The best way to install NodeJS
I guess, you have the latest ember-cli. You can update it if you are outside of your project:
$ cd ~
$ npm install -g ember-cli
I just cloned your repository.
$ git clone https://github.com/uioporqwerty/website.git
$ cd website
$ npm install && bower install
$ ember server
Got the following error:
➜ website git:(master) ember s
version: 2.4.2
The Broccoli Plugin: [ConfigLoader] failed with:
Error: Attempting to watch missing directory: config
at EventEmitter.Watcher_addWatchDir [as addWatchDir] (/Users/szines/projects/temp/website/node_modules/broccoli-sane-watcher/index.js:90:11)
at /Users/szines/projects/temp/website/node_modules/ember-cli-broccoli/lib/builder.js:95:35
...
Because of a couple of important files are missing from your ember-cli project, I just run ember init
$ ember init
During this process you see a question. You can check suggested changes with 'd', but it would just remove bootstrap and font-awesome, which is fine, because we will reinstall them with ember install.
[?] Overwrite bower.json? (Yndh) Y
Now we remove all the previous bower and npm package, temp folder and dist folder.
$ rm -rf bower_components node_modules tmp dist
$ npm install && bower install
Install ember-bootstrap and ember-font-awesome:
$ ember install ember-bootstrap
$ ember install ember-font-awesome
Launch the server:
$ ember server
Your app working like a charm. Open localhost:4200 in your browser.
You can build the production:
$ ember build --prod
And all the files will be in /dist folder.
Or run the production version with the server:
$ ember server --prod
Enjoy your new Ember! :)
Update:
You can use ember-cli-update for updating your Ember app:
$ npx ember-cli-update
$ npx ember-cli-update --run-codemods
Source: Update Ember.js app
Zoltan's answer was very helpful in being a part of the solution to my problem. After fixing my local website according to Zoltan's answer I noticed some issues.
First, there was the following error with Ember-Cli 2.4.2:
Could not find module ember-data/-private\system\references\record imported from ember-data/-private/system/references
This issue has been resolved in the master branch of the Github repo for ember-cli but it hasn't made its way to the npm repo. So what I did was uninstall ember-cli with npm remove -g ember-cli and then followed the development instructions on the github repo https://github.com/ember-cli/ember-cli. This fixed that issue.
Additionally, I noticed that my nginx server was not serving js and css files; I tested this by creating a index.html with test.css and test.js and noticed that the server wasn't dishing out those files. Instead of trying to find the issue I noticed my nginx was a bit out of date on my RPI, it was at version 1.6.x, so I thought this would be a good time to update it; I updated it to 1.9.7 by first removing the old version then running this script https://gist.github.com/MattWilcox/402e2e8aa2e1c132ee24. After that I had nginx 1.9.7 but I did somehow have apache2 installed which caused its own headaches with recognizing the default website so I removed it.
Finally, since my settings were overridden I restored /etc/nginx from an rsync backup I have of my pi by just copying over that directory.
Then boom, everything worked. It took a while but everything seems to be working great at https://www.uioporqwerty.com and the qualsys lab report is working fine too https://www.ssllabs.com/ssltest/analyze.html?d=www.uioporqwerty.com so all my settings carried over correctly :)
Glad to have Ember-Cli working correctly.

How do I make bower install work with aws.push?

As a starting point to making my own app that uses meanjs, I went to the meanjs website and used their yeomen generator to create the template/sample app. Following the instructions getting the sample application running out of the box on my local desktop machine worked within minutes. To complete the exercise I tried to deploy the sample app to an AWS/EC2 instance before making any changes to it. I have used the command line deployment tools in the past and liked it. Also it is nice how now you can just select an EC2 Linux instance with node and npm already installed and ready.
After checking the sample into git, I run "git aws.push" to deploy the app.
The problem is in the package.json the line:
"postinstall": "bower install --config.interactive=false"
In the eb-activity.log:
npm WARN cannot run in wd meansample#0.0.1 bower install --config.interactive=false (wd=/tmp/deployment/application)
The result is that AngularJS ends up not getting installed in /public/lib.
First thing I tried was giving the full path in the package.json file: node_modules/bower/bin/bower. This didn't help and results in the same error. Also noting that other commands like "grunt" don't need the full path specified in the package.json and they work.
I don't understand enough of the black box magic that aws.push does to understand why this error is happening. For example what user does it run as? What permissions does that user have? what options if any does it use when it runs npm install?
I did figure out a work-around, but it adds a lot of extra steps that shouldn't be required if aws.push was able to run bower install directly. Basically I can manually run the bower install in the ssh client connected to my EC2 instance, set the owner/group on the installed files, and restart the server.
Work-around steps:
1) On local command prompt run git aws.push. Wait for unsuccessfully deployment to finish.
2) Connect ssh client to EC2 instance. From the command prompt:
cd /var/app/current
/* NOTE: if I don't use sudo the ec2user I am logged in as does not have permission to create /public/lib needed to install AngularJS into*/
sudo node_modules/bower/bin/bower install --config.interactive=false --allow-root
/* NOTE: just changing the owner and group to match the same as the other files that aws.push deployed */
sudo chown -R nodejs public/lib
sudo chgrp -R nodejs public/lib
From AWS dashboard, select the correct EC2 instance, Action = Restart App Server(s)
Now AngularJS is install and the sample app works.
How do I eliminate the extra steps and make it so aws.push can do the bower install successfully?
I have experienced the same problem when trying to publish my nodejs app in a private server running CentOs using root user. The same error is fired by "postinstall": "./node_modules/bower/bin/bower install" in my package.json file so the only solution that was working for me is to use both options to avoid the error:
1: use --allow-root option for bower install command
"postinstall": "./node_modules/bower/bin/bower --allow-root install"
2: use --unsafe-perm option for npm install command
npm install --unsafe-perm